package com.example.spark.controller;

import com.example.spark.entity.result.CommonResult;
import com.example.spark.service.impl.FilesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;


@CrossOrigin
@RestController
@RequestMapping("/file")
public class FilesController {

    @Autowired
    private FilesServiceImpl filesService;

    // 新增（投递）简历
    @PostMapping(value = "/insertFiles/{user_id}")
    public CommonResult insertIntoFiles(@RequestParam("file") MultipartFile file, @PathVariable Long user_id) throws IOException {
        CommonResult commonResult = filesService.insertIntoFiles(file, user_id);
        return commonResult;
    }


    // 删除简历
    @DeleteMapping(value = "/deleteFiles/{id}")
    public CommonResult deleteFromFiles(@PathVariable Long id) {
        CommonResult commonResult = filesService.deleteFromFiles(id);
        return commonResult;
    }


    // 审核简历
    @PutMapping(value = "/updateFiles/{id}/{fileResult}")
    public CommonResult updateFiles(@PathVariable Long id, @PathVariable int fileResult) {
        CommonResult commonResult = filesService.updateFiles(id, fileResult);
        return commonResult;
    }


    // 简历列表
    @GetMapping("/PageFiles")
    public CommonResult getFilesListByPage(@RequestParam(value = "data") String fileDto) throws Exception {
            CommonResult commonResult = filesService.fileList(fileDto);
            return commonResult;
    }

}
